/* GUI CONVERTED from rcrp02a.p (converter v1.76) Fri May  3 13:21:33 2002 */
/* rcrp02a.p - Release Management Customer Schedules - Schedule Compare SubP  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10.1.7 $                                                      */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92           BY: WUG *F110*          */
/* REVISION: 7.0    LAST MODIFIED: 03/16/92           BY: WUG *F312*          */
/* REVISION: 7.0    LAST MODIFIED: 03/26/92           BY: WUG *F323*          */
/* REVISION: 7.3    LAST MODIFIED: 10/13/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 08/30/93           BY: WUG *GE19*          */
/* REVISION: 7.3    LAST MODIFIED: 10/25/94           BY: rxm *GN17*          */
/* REVISION: 7.3    LAST MODIFIED: 03/22/95           BY: aed *G0J0*          */
/* REVISION: 7.3    LAST MODIFIED: 10/07/95           BY: vrn *G0YL*          */
/* REVISION: 8.5    LAST MODIFIED: 10/25/95           BY: dpm *J044*          */
/* REVISION: 8.5    LAST MODIFIED: 02/21/96           BY: kjm *G1NR*          */
/* REVISION: 8.5    LAST MODIFIED: 10/15/96       BY: *G2GJ* Ajit Deodhar     */
/* REVISION: 8.5    LAST MODIFIED: 12/19/97       BY: *H1HL* Aruna Patil      */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98       BY: *L007* A. Rahane        */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98       BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E   LAST MODIFIED: 07/09/98       BY: *J2R0* Samir Bavkar     */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98       BY: *J314* Alfred Tan       */
/* REVISION: 8.6E   LAST MODIFIED: 08/19/99       BY: *K229* Surekha Joshi    */
/* REVISION: 9.0    LAST MODIFIED: 11/03/99       BY: *M0FB* Reetu Kapoor     */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00       BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00       BY: *N0KP* Mark Brown       */
/* REVISION: 9.1    LAST MODIFIED: 09/04/00       BY: *N0RB* Mudit Mehta      */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.10.1.6     BY: Jean Miller        DATE: 03/22/01  ECO: *P008*  */
/* $Revision: 1.10.1.7 $    BY: Katie Hilbert      DATE: 04/15/02  ECO: *P03J*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* SCHEDULE COMPARE SUBPROGRAM */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define shared variable impexp       like mfc_logical no-undo.

{rcordfrm.i}

FORM /*GUI*/ 
   {rcordfma.i}
with STREAM-IO /*GUI*/  frame prm side-labels width 80 attr-space.

/* SET EXTERNAL LABELS */
setFrameLabels(frame prm:handle).

define shared buffer schmstr1 for sch_mstr.
define shared buffer schmstr2 for sch_mstr.

define buffer schddet1 for schd_det.
define buffer schddet2 for schd_det.

define variable diff_qty       like ld_qty_oh label "Qty Diff" no-undo.
define variable cum_diff_qty   like ld_qty_oh label "Cum Qty Diff" no-undo.
define variable disp_date      like schd_date no-undo.
define variable disp_time      like schd_time format "XX:XX" no-undo.
define variable disp_interval  like schd_interval column-label "Int" no-undo.
define variable disp_reference like schd_reference format "x(24)" no-undo.
define variable first_pass     like mfc_logical initial yes no-undo.
define variable key1           as   character no-undo.
define variable key2           as   character no-undo.
define variable schedule_type  as   character extent 3 format "x(30)" no-undo.
define variable cum1_qty       like schd_cum_qty no-undo.
define variable cum2_qty       like schd_cum_qty no-undo.
define variable l_desc1        like pt_desc1   no-undo.
define variable l_ctr          as   integer    no-undo.

assign
   schedule_type[1] = getTermLabel("CUSTOMER_PLAN_SCHEDULE",30)
   schedule_type[2] = getTermLabel("CUSTOMER_SHIP_SCHEDULE",30)
   schedule_type[3] = getTermLabel("REQUIRED_PLAN_SCHEDULE",30).

find sod_det where
     sod_nbr = schmstr1.sch_nbr and
     sod_line = schmstr1.sch_line
no-lock no-error.

find scx_ref where
     scx_type = 1 and
     scx_order = sod_nbr and
     scx_line = sod_line
no-lock no-error.

find so_mstr where so_nbr = scx_order exclusive-lock.
find si_mstr where si_site = scx_shipfrom no-lock no-error.
find ad_mstr where ad_addr = scx_shipto no-lock no-error.
find pt_mstr where pt_part = scx_part no-lock no-error.

if available pt_mstr then
   l_desc1 = pt_desc1.
else if available sod_det then
   l_desc1 = sod_desc.
else
   l_desc1 = "".

{mfphead.i}

display
   scx_shipfrom
   scx_shipto
   ad_name         when (available ad_mstr)
   scx_part
   l_desc1    @ sod_desc
   sod_custpart    when (available sod_det)
   pt_um           when (available pt_mstr)
   scx_po
   scx_custref
   scx_modelyr
   skip(1)
   schmstr1.sch_type
   schedule_type[schmstr1.sch_type] no-label
   scx_order
   scx_line
   skip(1)
with frame prm STREAM-IO /*GUI*/ .

/* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
find first schddet1
     where schddet1.schd_type                   = schmstr1.sch_type
       and schddet1.schd_nbr                    = schmstr1.sch_nbr
       and schddet1.schd_line                   = schmstr1.sch_line
       and schddet1.schd_rlse_id                = schmstr1.sch_rlse_id
       and trim(substring(schddet1.schd_fc_qual,2,1)) = ""
no-lock no-error.

/* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
find first schddet2
     where schddet2.schd_type                   = schmstr2.sch_type
       and schddet2.schd_nbr                    = schmstr2.sch_nbr
       and schddet2.schd_line                   = schmstr2.sch_line
       and schddet2.schd_rlse_id                = schmstr2.sch_rlse_id
       and trim(substring(schddet2.schd_fc_qual,2,1)) = ""
no-lock no-error.

repeat while available schddet1 or available schddet2
with frame f-a:

   
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   l_ctr = l_ctr + 1.

   FORM /*GUI*/ 
      disp_date
      disp_time
      disp_interval
      disp_reference
      schddet1.schd_discr_qty   column-label "Discrete!Qty"
      schddet1.schd_cum_qty     column-label "Cumulative!Qty"
      schddet1.schd_fc_qual
      schddet2.schd_discr_qty   column-label "Discrete!Qty"
      schddet2.schd_cum_qty     column-label "Cumulative!Qty"
      schddet2.schd_fc_qual
      diff_qty
      cum_diff_qty
   with STREAM-IO /*GUI*/  frame f-a width 132 no-box.

   setFrameLabels(frame f-a:handle). /* SET EXTERNAL LABELS */

   FORM /*GUI*/  header
      getTermLabel("RELEASE_ID",20)     at 47 format "x(20)"
      getTermLabel("RELEASE_ID",20)     at 77 format "x(20)"
      fill("-",27) format "x(27)"       at 47
      fill("-",27) format "x(27)"       at 77
      (if available schddet1 then schddet1.schd_rlse_id else "" )
         format "x(30)" at 47
      (if available schddet2 then schddet2.schd_rlse_id else "" )
         format "x(30)" at 77
      " "                               at 47
   with STREAM-IO /*GUI*/  frame f-hdr-a width 132 no-box.

   view frame f-hdr-a.

   /* IN THE RSS, CUMULATIVE QTY CALCULATION IS CHANGED SO THAT    */
   /* THE QUANTITY EFFECTS OF THE LINES THAT ARE NOT DISPLAYED IS  */
   /* NOT REFLECTED IN THE CUMULATIVE DATA OF SUBSEQUENT LINES     */
   if first_pass then do:
      assign
         cum1_qty = schmstr1.sch_pcr_qty
         cum2_qty = schmstr2.sch_pcr_qty.

      display
         getTermLabel("PRIOR",8) @ disp_date
         schmstr1.sch_pcr_qty @ schddet1.schd_cum_qty
         schmstr2.sch_pcr_qty @ schddet2.schd_cum_qty
         schmstr2.sch_pcr_qty - schmstr1.sch_pcr_qty
            @ cum_diff_qty WITH STREAM-IO /*GUI*/ .

      down 1.

      first_pass = no.
   end.

   if available schddet1 then
      key1 = string(year(schddet1.schd_date),"9999")
           + string(month(schddet1.schd_date),"99")
           + string(day(schddet1.schd_date),"99")
           + string(schddet1.schd_time,"x(4)")
           + string(schddet1.schd_interval,"x(1)")
           + schddet1.schd_reference.

   if available schddet2 then
      key2 = string(year(schddet2.schd_date),"9999")
           + string(month(schddet2.schd_date),"99")
           + string(day(schddet2.schd_date),"99")
           + string(schddet2.schd_time,"x(4)")
           + string(schddet2.schd_interval,"x(1)")
           + schddet2.schd_reference.

   if available schddet1 and
      (not available schddet2 or key1 < key2)
   then do:

      cum1_qty = cum1_qty + schddet1.schd_discr_qty.
      if l_ctr = 1 then
         cum2_qty = schmstr2.sch_pcr_qty.
      diff_qty =  - schddet1.schd_discr_qty.
      cum_diff_qty = cum2_qty - cum1_qty.

      display
         schddet1.schd_date @ disp_date
         schddet1.schd_time format "XX:XX"
            when (schddet1.schd_time <> "") @ disp_time
         schddet1.schd_interval @ disp_interval
         schddet1.schd_reference @ disp_reference
         schddet1.schd_discr_qty
         cum1_qty @ schddet1.schd_cum_qty
         schddet1.schd_fc_qual
         diff_qty when (diff_qty <> 0)
         cum_diff_qty when (cum_diff_qty <> 0) WITH STREAM-IO /*GUI*/ .

      /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
      find next schddet1
          where schddet1.schd_type  = schmstr1.sch_type
            and schddet1.schd_nbr     = schmstr1.sch_nbr
            and schddet1.schd_line    = schmstr1.sch_line
            and schddet1.schd_rlse_id = schmstr1.sch_rlse_id
            and trim(substring(schddet1.schd_fc_qual,2,1)) = ""
      no-lock no-error.

   end.

   else
   if available schddet2 and
      (not available schddet1 or key2 < key1)
   then do:

      cum2_qty = cum2_qty + schddet2.schd_discr_qty.
      if l_ctr = 1 then
         cum1_qty = schmstr1.sch_pcr_qty.
      diff_qty = schddet2.schd_discr_qty.
      cum_diff_qty = cum2_qty - cum1_qty.

      display
         schddet2.schd_date @ disp_date
         schddet2.schd_time format "XX:XX"
            when (schddet2.schd_time <> "") @ disp_time
         schddet2.schd_interval @ disp_interval
         schddet2.schd_reference @ disp_reference
         schddet2.schd_discr_qty
         cum2_qty @ schddet2.schd_cum_qty
         schddet2.schd_fc_qual
         diff_qty when (diff_qty <> 0)
         cum_diff_qty when (cum_diff_qty <> 0) WITH STREAM-IO /*GUI*/ .

      /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
      find next schddet2
          where schddet2.schd_type  = schmstr2.sch_type
            and schddet2.schd_nbr     = schmstr2.sch_nbr
            and schddet2.schd_line    = schmstr2.sch_line
            and schddet2.schd_rlse_id = schmstr2.sch_rlse_id
            and trim(substring(schddet2.schd_fc_qual,2,1)) = ""
      no-lock no-error.

   end.

   else do:

      assign
         cum1_qty = cum1_qty + schddet1.schd_discr_qty
         cum2_qty = cum2_qty + schddet2.schd_discr_qty
         diff_qty = schddet2.schd_discr_qty - schddet1.schd_discr_qty
         cum_diff_qty = cum2_qty - cum1_qty.

      display
         schddet1.schd_date @ disp_date
         schddet1.schd_time format "XX:XX"
            when (schddet1.schd_time <> "") @ disp_time
         schddet1.schd_interval @ disp_interval
         schddet1.schd_reference @ disp_reference
         schddet1.schd_discr_qty
         cum1_qty @ schddet1.schd_cum_qty
         schddet1.schd_fc_qual
         schddet2.schd_discr_qty
         cum2_qty @ schddet2.schd_cum_qty
         schddet2.schd_fc_qual
         diff_qty when (diff_qty <> 0)
         cum_diff_qty when (cum_diff_qty <> 0) WITH STREAM-IO /*GUI*/ .

      /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
      find next schddet1
          where schddet1.schd_type  = schmstr1.sch_type
            and schddet1.schd_nbr     = schmstr1.sch_nbr
            and schddet1.schd_line    = schmstr1.sch_line
            and schddet1.schd_rlse_id = schmstr1.sch_rlse_id
            and trim(substring(schddet1.schd_fc_qual,2,1)) = ""
      no-lock no-error.

      /* DO NOT DISPLAY/PRINT COMPLETELY SHIPPED SCHD_DET RECORDS */
      find next schddet2
          where schddet2.schd_type  = schmstr2.sch_type
            and schddet2.schd_nbr     = schmstr2.sch_nbr
            and schddet2.schd_line    = schmstr2.sch_line
            and schddet2.schd_rlse_id = schmstr2.sch_rlse_id
            and trim(substring(schddet2.schd_fc_qual,2,1)) = ""
      no-lock no-error.

   end.

end.
